package org.imraniqbal.engine;

import java.util.Vector;

/**
 * @author  imran
 */
public abstract class Game {
	private Vector<GameListener> GameList;
	/**
	 * @uml.property  name="map"
	 * @uml.associationEnd  
	 */
	private Map map;
	/**
	 * @uml.property  name="score"
	 */
	private int score;
	private boolean didUWin;
	/**
	 * Creates a new game
	 * @author imran
	 */
	public Game(){
		GameList = new Vector<GameListener>();
	}
	/**
	 * @return   Current Map of game
	 * @author  imran
	 * @uml.property  name="map"
	 */
	public Map getMap() {
		return map;
	}
	/**
	 * Allows you to change current map of game
	 * @param map   new map that you want game to use"
	 * @author  imran
	 * @uml.property  name="map"
	 */
	public void setMap(Map map) {
		this.map = map;
	}
	/**
	 * @return   Current score of game
	 * @author  imran
	 * @uml.property  name="score"
	 */
	public int getScore(){
		return score;
	}
	/**
	 * Allows you to change current score of game
	 * @param score  new score that you want to have
	 * @author  imran
	 * @uml.property  name="score"
	 */
	public void setScore(int score){
		this.score = score;
	}
	/**
	 * Allows you to change whether or not you have won
	 * @param win new win state that you want to have
	 * @author imran
	 */
	public void setWin( boolean win){
		this.didUWin = win;
	}
	/**
	 * @return  Current win state of game
	 * @author imran
	 */
	public boolean getWin(){
		return didUWin;
	}
	/**
	 * Lets you add listeners for events
	 * @param g Listener to be added
	 * @author imran
	 */
	public void addListener(GameListener g){
		GameList.add(g);
	}
	/**
	 * Notifies all listeners of Event
	 * @param e Event that needs to be sent to listeners
	 * @author imran
	 */
	public void notify(GameEvent e){
		for( GameListener g : GameList){
			g.onEvent(e);
		}
	}
	
	/**
	 * A method to initiate the game
	 * @author imran
	 */
	public abstract void start();
	
	/**
	 * A method to check if the game has ended
	 */
	public abstract boolean hasEnded();
	
	/**
	 * Receives input from the Game controller
	 * @param control the control that was received
	 */
	public abstract void getControl(GameController.Controls control);
}
